<?php
if (isset($_POST['o']) &&  !empty($_POST['o']) ){
    include 'load.php';
    $openid=$_POST['o'];
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $query=$mysqli->query("SELECT id FROM `orders` where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        
    }else{
        $query=$mysqli->query("SELECT id FROM `users` where openid='".$openid."' limit 0,1 ");
        $userInfo=$query->fetch_array();
        $uid=$userInfo['id'];
        $orderId=$uid. '_' . date('YmdHis') . '_' . rand(100,999);
        $mysqli->query("insert into orders(openid,order_id,isshot,createtime) values('".$openid."','".$orderId."',0,'".date("Y-m-d H:i:s")."')  ");  
        
    }
    
    $mysqli->query("update uinfo set queren='yes' where openid='".$openid."'  ");

}